package com.atguigu.jxc.controller;

import com.atguigu.jxc.domain.ServiceVO;
import com.atguigu.jxc.domain.SuccessCode;
import com.atguigu.jxc.entity.PurchaseList;
import com.atguigu.jxc.entity.ReturnList;
import com.atguigu.jxc.service.PurchaseService;
import com.atguigu.jxc.service.ReturnService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/returnListGoods")
public class ReturnListController {
    @Autowired
    private ReturnService returnService;
    //http://localhost:8080/returnListGoods/save?returnNumber=TH1605768591211
    //退货单保存
    @PostMapping("/save")
    public ServiceVO save(ReturnList returnList, String returnListGoodsStr){
       this.returnService.saveReturnList(returnList,returnListGoodsStr);
       return new ServiceVO(SuccessCode.SUCCESS_CODE,SuccessCode.SUCCESS_MESS);
    }
    @PostMapping("/list")
    public Map<String,Object> list(String purchaseNumber, Integer supplierId, Integer state, String sTime, String eTime){
        return returnService.getReturnList(purchaseNumber,supplierId,state,sTime,eTime);
    }
    @PostMapping("/goodsList")
    public Map<Object, Object> goodsList(Integer returnListId){
        return returnService.getReturnListGoods(returnListId);
    }
    @PostMapping("/delete")
    public ServiceVO delete(Integer returnListId) {
        this.returnService.returnDelete(returnListId);
        return new ServiceVO(SuccessCode.SUCCESS_CODE,SuccessCode.SUCCESS_MESS);
    }
    //退货统计
    @PostMapping("/count")
    public List<ReturnList> getReturnCount(String sTime, String eTime ,Integer goodsTypeId, String codeOrName){
        return returnService.getReturnCount(sTime,eTime,goodsTypeId,codeOrName);
    }
}
